<template>
  <div id="pool">

    <el-card class="box-card">
      <div slot="header" class="clearfix">
        <span>全网流动矿池总量（{{ params.orderTotal }}）</span>
      </div>
      <div>
        <el-row>
          <el-col :span="15">
            <div class="">
              <!-- <div>公司收益</div> -->
              <div class="grid-content ">请输入需要增加的数量 <div><el-input v-model="params.amount" style="width:300px;" placeholder="请输入增加量" @input="params.amount=setnumber(params.amount)" /> </div> </div>
            </div>
          </el-col>
          <!-- <el-col :span="5">

            <div class="grid-content ">运维收益: <div><el-input v-model="params.gs" style="width: 100px;" placeholder=""></el-input> %</div> </div>
          </el-col> -->

          <el-col :span="9">
            <div class="grid-content" style="margin-left: 100px;"><el-button type="primary" size="min" @click="okseve(params)">确认</el-button></div>
          </el-col>

        </el-row>
        <!-- <el-divider></el-divider> -->
      </div>

    </el-card>
  </div>
</template>
<script>
import { getpoollist, setpoollist } from '@/api/data1.js'
export default {
  name: 'Pool',
  data() {
    return {
      params: {
        amount: '',
        type: '3',
        orderTotal: ''
      }

    }
  },
  mounted() {
    this.getlist()
  },
  methods: {
    setnumber(params) {
      params = params || 0
      if (params == '') {
        return
      }
      params = params.replace(/[^\d.]/g, '') // 清除“数字”和“.”以外的字符
      params = params.replace(/\.{2,}/g, '.') // 只保留第一个. 清除多余的
      params = params.replace('.', '$#$').replace(/\./g, '').replace('$#$', '.')
      params = params.replace(/^(\-)*(\d+)\.(\d\d\d\d\d\d).*$/, '$1$2.$3')// 只能输入两个小数
      if (params.indexOf('.') < 0 && params != '') { // 以上已经过滤，此处控制的是如果没有小数点，首位不能为类似于 01、02的金额
        params = parseFloat(params)
      }
     
   
      return params
      // console.log(price)
    },

    async getlist() {
      const { data, code } = await getpoollist()

      if (code == 0) {
        this.params.amount = data.increments
        this.params.orderTotal = data.orderTotal
      }
    },

    async okseve(params) {
      const res = await setpoollist(params)
      if (res.code == 0) {
        this.getlist()
        this.$message('保存成功')

      }
      console.log(obj)
      // this.$message('我是确定')
    }
  }
}
</script>
<style lang="scss" >
  .box-card{
    width: 97%;
    margin: 0 auto;
    margin-top: 20px;
  }
  #pool{
    .listbox{
      /* border-bottom: 1px solid #dddddd56; */
      margin-top: 40px;
    }
  }
  .el-row {
    margin-bottom: 20px;
    &:last-child {
      margin-bottom: 0;
    }
  }
  .el-col {
    border-radius: 4px;
  }
  .bg-purple-dark {
    background: #99a9bf;
  }
  .bg-purple {
    background: #d3dce6;
  }
  .bg-purple-light {
    background: #e5e9f2;
  }
  .grid-content {
    /* border-radius: 4px;
    min-height: 36px; */
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
  }
  .row-bg {
    padding: 10px 0;
    background-color: #f9fafc;
  }
</style>

</style>
